package servlet;

import pojo.Brand;
import service.BrandService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
//修改的第一步：数据回显（/toUpdate）
@WebServlet(name = "ToUpdateServlet", value = "/toUpdate")
public class ToUpdateServlet extends HttpServlet {

    private BrandService brandService = new BrandService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.接受一个id(待修改品牌id
        String id = request.getParameter("id");
        Integer idd=Integer.valueOf(id);
        //2. 调用service层的方法进行查询
        Brand brand = brandService.selectById(idd);
        System.out.println(brand);
        //3.将查询结果存储到request中

        request.setAttribute("brand",brand);
        //4. 转发到update.jsp，进行展示
        request.getRequestDispatcher("/updateBrand.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
